package com.thinkcube.edutainment.adapters;

import java.util.List;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.thinkcube.edutainment.domain.data.QuestionData;
import com.thinkcube.edutainment.service.viewitem.QuestionItem;
import com.thinkcube.edutainment.service.viewitem.QuestionItem_;

@EBean
public class QuestionAdapter extends BaseAdapter {

	List<QuestionData> questionData;

	@RootContext
	Context context;

	@Override
	public View getView(final int position, final View convertView,
			final ViewGroup parent) {

		QuestionItem questionItem;
		if (convertView == null) {
			questionItem = QuestionItem_.build(context);
		} else {
			questionItem = (QuestionItem) convertView;
		}

		questionItem.bind(getItem(position));

		return questionItem;
	}

	public List<QuestionData> getquestionData() {
		return questionData;
	}

	public void setquestionData(List<QuestionData> questionData) {
		this.questionData = questionData;
	}

	@Override
	public int getCount() {
		return questionData.size();
	}

	@Override
	public QuestionData getItem(final int position) {
		return questionData.get(position);
	}

	@Override
	public long getItemId(final int position) {
		return position;
	}

}
